package gunfire.relics;

import basemod.abstracts.CustomRelic;
import com.badlogic.gdx.graphics.Texture;
import com.megacrit.cardcrawl.actions.common.ApplyPowerAction;
import com.megacrit.cardcrawl.actions.common.RelicAboveCreatureAction;
import com.megacrit.cardcrawl.actions.utility.UseCardAction;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.powers.watcher.FreeAttackPower;
import com.megacrit.cardcrawl.relics.AbstractRelic;
import gunfire.GunfireMod;
import gunfire.util.TextureLoader;

import static gunfire.GunfireMod.makeRelicOutlinePath;
import static gunfire.GunfireMod.makeRelicPath;

public class ArmsDealer extends CustomRelic {

    public static final String ID = GunfireMod.makeID("ArmsDealer");
    private static final Texture IMG = TextureLoader.getTexture(makeRelicPath("ArmsDealer.png"));
    private static final Texture OUTLINE = TextureLoader.getTexture(makeRelicOutlinePath("blank.png"));

    public ArmsDealer() {
        super(ID, IMG, OUTLINE, RelicTier.UNCOMMON, LandingSound.CLINK);
        this.counter = 0;
    }

    @Override
    public void onUseCard(AbstractCard targetCard, UseCardAction useCardAction) {
        this.counter++;
        if (this.counter == 10) {
            this.counter = 0;
            this.flash();
            this.pulse = false;
            AbstractPlayer p = AbstractDungeon.player;
            this.addToBot(new RelicAboveCreatureAction(p, this));
            this.addToBot(new ApplyPowerAction(p, p, new FreeAttackPower(p, 1), 1));
        } else if (this.counter == 9) {
            this.beginPulse();
            this.pulse = true;
        }
    }

    @Override
    public void atBattleStart() {
        if (this.counter == 9) {
            this.beginPulse();
            this.pulse = true;
        }
    }

    @Override
    public String getUpdatedDescription() {
        return DESCRIPTIONS[0];
    }

    @Override
    public AbstractRelic makeCopy() {
        return new ArmsDealer();
    }
}
